package com.appspot.modutajataja;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageButton;

public class GameActivity extends Activity {
	ImageButton touch_game;
	ImageButton moa_game;
	ImageButton crash_game;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_game);

		Context mContext = getApplicationContext();
		LayoutInflater inflater = (LayoutInflater) mContext
				.getSystemService(LAYOUT_INFLATER_SERVICE);
		View layout = inflater.inflate(R.layout.game_select_dialog,
				(ViewGroup) findViewById(R.id.layout_root));

		AlertDialog.Builder aDialog = new AlertDialog.Builder(GameActivity.this);
		aDialog.setView(layout);

		aDialog.setNegativeButton("����", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int which) {
			}
		});
		AlertDialog ad = aDialog.create();
		ad.show();

		touch_game = (ImageButton) findViewById(R.id.gs_btn1);
		touch_game.setOnClickListener(new GameHandler());

		moa_game = (ImageButton) findViewById(R.id.gs_btn2);
		moa_game.setOnClickListener(new GameHandler());

		crash_game = (ImageButton) findViewById(R.id.gs_btn3);
		crash_game.setOnClickListener(new GameHandler());
	}

	class GameHandler implements OnClickListener {

		@Override
		public void onClick(View v) {

			if (v.getId() == R.id.gs_btn1) {
				Intent intent = new Intent(GameActivity.this, TouchGame.class);
				startActivity(intent);
			} else if (v.getId() == R.id.gs_btn2) {
				Intent intent = new Intent(GameActivity.this, MoaGame.class);
				startActivity(intent);
			} else if (v.getId() == R.id.gs_btn3) {
				Intent intent = new Intent(GameActivity.this, CrashGame.class);
				startActivity(intent);
			}
		}
	} // end of MyHandler Class
};